package com.sghd.fight.module.game.event;

import com.sghd.common.event.AbstractReceiver;
import com.sghd.common.socket.core.Message;
import com.sghd.common.socket.session.SessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PushEventReceiver extends AbstractReceiver<PushEvent> {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private SessionManager sessionManager;

    @Override
    public void doEvent(PushEvent event) {
        Message message = Message.valueOf(event.getCommand(), event.getBody());
        sessionManager.send(message, event.getPlayerIds().toArray());
    }

    @Override
    public String[] getEventNames() {
        return new String[]{PushEvent.NAME};
    }

}
